package com.szrt.java.day20161227.demo03;


import java.util.Arrays;

import org.junit.Test;

public class ArrayAddTest01 {
	
	
	@Test
	public void add() {
		
		int[] oldArray = new int[]{5,4,3,2,1};
		
		int num =9;
		
		int len = oldArray.length;
		
		//1 造1个数组 类型一样 数组的长度是原来的长度+1
		int[] newArray = new int[len+1];
		
		System.out.println(Arrays.toString(newArray));
		
		//2 把原来的数组中的值依次复制过来  循环
		
		for(int index =0 ;index<len;index++){
			//拿到老的值
			int value = oldArray[index];
			newArray[index] = value;
		}
		System.out.println(Arrays.toString(newArray));
		newArray[len]=num;
		System.out.println(Arrays.toString(newArray));
	}

}
